from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class LoginPage(BasePage):
    url = '/login'
    username_locater = (By.XPATH,'//*[@id="mobile"]')
    password_locater = (By.XPATH,'//*[@id="password"]')
    check_locater = (By.XPATH, '//*[@id="root"]/div/div/div/div/form/div[3]/div/div/div/span')
    end_point_locater = (By.XPATH,'//*[@id="root"]/div/div/div/div/form/div[3]/div/span')
    submit_locater = (By.CSS_SELECTOR,'#root > div > div > div > div > form > button')

    def input_username(self, username):
        """输入用户名"""
        self.send_keys(self.username_locater,username)

    def input_password(self,password):
        """输入密码"""
        self.send_keys(self.password_locater,password)

    def goat_erp_login(self,username,password):
        """登录goaterp"""
        self.open()
        self.input_username(username)
        self.input_password(password)
        self.drag_and_drop(self.check_locater,self.end_point_locater)
        self.click(self.submit_locater)
